﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Windows.Controls.Primitives;

namespace Silverlight.Controls.ToolTips.Tests
{
    [TestClass]
    public class ToolTipServiceTests
    {
        private UIElement owner;
        private ToolTip toolTip;

        [TestInitialize]
        public void Initialize()
        {
            // initialize a ToolTip instance
            toolTip = new ToolTip();
            toolTip.Content = "Some content";

            // initialize a UIElement to own the ToolTip instance
            owner = new Button();

            // set the ToolTip on the owner using the ToolTipService
            ToolTipService.SetToolTip(owner, toolTip);
        }

        [TestMethod]
        public void ToolTipServiceHasRootVisual()
        {
            Assert.IsNotNull(ToolTipService.RootVisual);
        }

        [TestMethod]
        public void GetToolTipRetrievesToolTip()
        {
            Assert.AreEqual(ToolTipService.GetToolTip(owner), toolTip);
        }

        [TestMethod]
        public void SetPlacementModeUpdatesToolTip()
        {
            ToolTipService.SetPlacement(toolTip, PlacementMode.Bottom);
            Assert.AreEqual(ToolTipService.GetPlacement(toolTip), PlacementMode.Bottom);
        }

        [TestMethod]
        public void SetPlacementTargetUpdatesTarget()
        {
            ToolTipService.SetPlacementTarget(toolTip, owner);
            Assert.AreEqual(owner, ToolTipService.GetPlacementTarget(toolTip));
        }
    }
}